﻿#ifndef DEVICEDLG_H
#define DEVICEDLG_H

#include "db_cfg_g_def.h"
#include "DbCfgFun.h"
#include <QListWidget>
#include <QListWidgetItem>
#include <QString>
#include <QVariant>
#include <QDialog>
#include <QComboBox>
#include <QLineEdit>
#include <QMessageBox>
#include "GetColumnInfo.h"

#pragma once

namespace Ui 
{
    class DeviceDlg;
}

class DeviceDlg : public QDialog 
{
    Q_OBJECT
public:
    DeviceDlg(unsigned int ParentId, QWidget *parent = 0);
    ~DeviceDlg();

public:
/*	函数：	GetDeviceModelInfo()
	用途：	获取设备模板信息
	输入：
	返回：	*/
	int		GetDeviceModelInfo();

/*	函数：	InitDevModeInfoShow()
	用途：	显示设备模板信息
	输入：
	返回：	*/
	void	InitDevModeInfoShow();

/*	函数：	InitListShow()
	用途：	初始化设备模板列表显示
	输入：
	返回：	*/
	void	InitListShow();

/*	函数：	InsertDevice()
	用途：	插入设备
	输入：
	返回：	*/
	int	InsertDevice();

/*	函数：	InsertYx()
	用途：	插入遥信
	输入：
	返回：	*/


	//	插入遥信
	int	 InsertYx_Old(unsigned int DeviceId, unsigned int ModelId, char *pDevName, bool b61850Model);
	int	 InsertYc_Old(unsigned int DeviceId, unsigned int ModelId, char *pDevName);
	int	 InsertYk_Old(unsigned int DeviceId, unsigned int ModelId, char *pDevName);
	int	 InsertYm_Old(unsigned int DeviceId, unsigned int ModelId, char *pDevName);
	int	 InsertBhYc_Old(unsigned int DeviceId, unsigned int ModelId, char *pDevName);
	int	 InsertRyb_Old(unsigned int DeviceId, unsigned int ModelId, char *pDevName);
	int	 InsertSet_Old(unsigned int DeviceId, unsigned int ModelId);
	int	 InsertParam_Old(unsigned int DeviceId, unsigned int ModelId);
	int	 InsertPrec_Old(unsigned int DeviceId, unsigned int ModelId);

	int	InsertYx_New(unsigned int DeviceId, unsigned int ModelId, char *pDevName, bool b61850Model);
	int	InsertYc_New(unsigned int DeviceId, unsigned int ModelId, char *pDevName);
	int	InsertYk_New(unsigned int DeviceId, unsigned int ModelId, char *pDevName);
	int	InsertYm_New(unsigned int DeviceId, unsigned int ModelId, char *pDevName);
	int	InsertBhYc(unsigned int DeviceId, unsigned int ModelId, char *pDevName);
	int	InsertRyb(unsigned int DeviceId, unsigned int ModelId, char *pDevName);
	int	InsertSet(unsigned int DeviceId, unsigned int ModelId);
	int	InsertParam(unsigned int DeviceId, unsigned int ModelId);
	int	InsertPrec(unsigned int DeviceId, unsigned int ModelId);
	int InserSetArea(unsigned int DeviceId, unsigned int ModelId);



protected slots:
/*	函数：	DevModelClicked()
	用途：	选择设备模板
	输入：
	返回：	*/
	void	DevModelClicked(QListWidgetItem *pItem);

/*	函数：	DeviceAddrEdit()
	用途：	编辑设备地址
	输入：
	返回：	*/
	void	DeviceAddrEdit();

/*	函数：	CheckDeviceParam()
	用途：	判断设备参数
	输入：
	返回：	*/
	void	CheckDeviceParam();
signals:
	void	RefreshData_Signal();
	void	UpDateTreeItem_Signal(quint32 AppType, quint32 TableId, quint32 ParentId, quint32 RecordId, int RowProp);
protected:
    void changeEvent(QEvent *e);

protected:
	unsigned int	m_DevModelId;
	int	m_YxNum;
	int	m_YcNum;
	int	m_YkNum;
	int	m_YmNum;
	int	m_SetNum;
	int	m_BhycNum;
	int	m_ParaNum;
	int	m_PrecNum;
	int	m_RybNum;
	int m_SetAreaNum;//ccg

	char	m_ProtectType;

	unsigned int	m_ParentId;
	unsigned int	m_RtuId;
	int	m_DeviceAddr;
	QString	m_DeviceName;
	QString	m_DevByName;

	bool	m_bAppendDevNameFlag;
	bool	m_bAddYxStateFlag;
	bool  m_bAddGooseFlag;
protected:
	GetColumnInfo	m_ColInfo;

	char		 m_sql[SQL_MAX_LEN];
	char		 m_Dsql[SQL_MAX_LEN*2];
private:
	Ui::DeviceDlg *ui;

//	DbCfgFun		g_DbCfgFunObj;

};

#endif // DEVICEDLG_H
